package com.bdqn.tour.service.impl;


import com.bdqn.tour.dao.HzyInvoiceDao;
import com.bdqn.tour.dao.impl.HzyInvoiceDaoImpl;
import com.bdqn.tour.pojo.HzyInvoice;
import com.bdqn.tour.pojo.HzyPageInfo;
import com.bdqn.tour.service.HzyInfoService;
import com.bdqn.tour.service.HzyInvoiceService;

import java.util.List;

public class HzyInvoiceServiceImpl implements HzyInvoiceService {
    HzyInvoiceDao HzyInvoiceDao = new HzyInvoiceDaoImpl();
    @Override
    public int addInvoice(HzyInvoice invoice) {
        return HzyInvoiceDao.addInvoice(invoice);
    }

    @Override
    public HzyPageInfo<HzyInvoice> getInvoice(int pageNo, int pageSize) {
        HzyPageInfo<HzyInvoice> pageInfo = new HzyPageInfo<>();

        // 设置当前页和每页大小
        pageInfo.setCurrPageNo(pageNo);
        pageInfo.setPageSize(pageSize);

        // 获取总记录数
        int totalCount = getInvoiceCount();
        pageInfo.setTotals(totalCount);

        // 获取当前页数据
        List<HzyInvoice> list = HzyInvoiceDao.getInvoice(pageNo, pageSize);
        pageInfo.setList(list);

        return pageInfo;
    }

    @Override
    public int getInvoiceCount() {
        return HzyInvoiceDao.getInvoiceCount();
    }

    @Override
    public int delInvoice(int id) {
        return HzyInvoiceDao.delInvoice(id);
    }
}
